﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MaquinaJMG.GUI.Contrato;
using MaquinaJMG.GUI.Presentador;
using Dolinay;
using System.IO;

namespace MaquinaJMG.GUI.Vista
{
    public partial class PendriveExportar : Form,IContratoExportarPendrive
    {
        private DriveDetector driveDetector = null;
        PresentadorExportarPendrive presenatdor;
        public PendriveExportar()
        {
            presenatdor = new PresentadorExportarPendrive();
            InitializeComponent();
            driveDetector = new DriveDetector();
            driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived);
            driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved);
            driveDetector.QueryRemove += new DriveDetectorEventHandler(OnQueryRemove);
            MessageBox.Show("Introduzca Pendrive", "Info",
               MessageBoxButtons.OK, MessageBoxIcon.Question);
        }

        // Called by DriveDetector when removable device in inserted 
        private void OnDriveArrived(object sender, DriveDetectorEventArgs e)
        {
            // Report the event in the listbox.
            // e.Drive is the drive letter for the device which just arrived, e.g. "E:\\"
            presenatdor.exportarPendrive(e.Drive + "/apuestas.xml");
            MessageBox.Show("Puede retirar el dispositivo", "Query remove",
                   MessageBoxButtons.OK, MessageBoxIcon.Question);
            this.Dispose(true);
           
            // If you want to be notified when drive is being removed (and be able to cancel it), 
            // set HookQueryRemove to true                
        }

        // Called by DriveDetector after removable device has been unpluged 
        private void OnDriveRemoved(object sender, DriveDetectorEventArgs e)
        {
        }

        // Called by DriveDetector when removable drive is about to be removed
        private void OnQueryRemove(object sender, DriveDetectorEventArgs e)
        {
            // Should we allow the drive to be unplugged?
           
        }
        

        // User checked the "Ask me before drive can be disconnected box"        
      


    }
}